//血氧数据
function getTime(num1, num2) {

    $.ajax({
                url: `${Url}/Wechat/Api/PeriodOxygenLevel?IdentityNo=${theRequest.IdentityNo}&BeginTime=${num1}&EndTime=${num2}`,
                type: 'get',
                datatype: 'json',
                // data: responseData,
                headers: {
                    'Authorization': Authorization
                },
                async: false,
                success: function(res) {
                        var CheckDate = [];
                        var Oxygen = [];
                        var Pulse = [];
                        var startLength = 100 - (5 / CheckDate.length * 100);
                        var num6 = res.data.OxygenLevelItems;
                        if (num6.length > 0) {
                            $('#tabletext').css('display', 'block')
                            for (let key in num6) {
                                var con = num6[key]
                                CheckDate.push(con.CheckDate);
                                Oxygen.push(con.Oxygen);
                                Pulse.push(con.Pulse);
                            }
                        } else {
                            CheckDate = ' ';
                            // Oxygen = ' ';
                            // Pulse = '';
                            $('#tabletext').css('display', 'none')
                        }

                        let teplhtml = `
                              ${num6.map(item=>{
                                return `<tr><td>${item.CheckDate}</td><td>${item.Oxygen}</td><td>${item.Pulse}</td></tr>`
                            }).join('')
                        }
                             `
            $('#tabletext').html(teplhtml);
            //舒张压
            var myChart1 = echarts.init(document.getElementById('main1'));
            option1 = {
                title: {
                    text: '血氧检测数据',
                    subtext: '血氧饱和度参考值:97~100%',
                    x: 'right',

                },
                grid: {


                    top: "30%",
                    right: "10%",
                    bottom: '20%',
                    //     width: "66%",
                    left: "10%",
                    //     containLabel: true,
                    //     height: "55%"
                },
                legend: {
                    orient: 'vertical',
                    x: 'left',
                    y: 'top',
                    data: ['血氧饱和度'],

                },
                xAxis: {
                    show:false,
                    data: CheckDate,
                    axisLabel: {
                        interval: 0,
                    },

                },
                yAxis: {
                    max: 100,
                    min: 90
                },
                series: [{
                    name: '血氧饱和度',
                    type: 'line',
                    data: Oxygen,
                    markLine: {
                        symbol: ['none', 'none'], //去掉箭头
                        itemStyle: {
                            normal: {
                                lineStyle: {
                                    type: 'dashed',
                                    color: { //设置渐变
                                        type: 'linear',
                                        // x: 0,
                                        y: 0,
                                        x2: 0,
                                        y2: 1,
                                        colorStops: [{
                                            offset: 0,
                                            color: 'red ' // 0% 处的颜色
                                        }, {
                                            offset: 1,
                                            color: 'red' // 100% 处的颜色
                                        }],
                                        global: false // 缺省为 false
                                    }
                                },
                            }
                        },
                        data: [{
                            yAxis: 97,
                        }, {
                            yAxis: 100,
                        }]
                    },

                }, ],
                color: ['#3366CC'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'line'
                    }
                },
                dataZoom: [ //滑动条
                    {
                        type: 'inside',
                        realtime: true,
                        start: startLength,
                        end: 100,
                        startValue: 0
                    }
                ],

            };
            myChart1.setOption(option1);

            var myChart2 = echarts.init(document.getElementById('main2'));
            option2 = {
                title: {
                    text: '心率检测数据',
                    subtext: '心率参考值:60~100次/分',
                    x: 'right',

                },
                grid: {
                    top: "30%",
                    right: "10%",
                    bottom: '20%',
                    left: "10%",
                },
                legend: {
                    orient: 'vertical',
                    x: 'left',
                    y: 'top',
                    data: ['心率'],

                },
                xAxis: {
                    data: CheckDate,
                    show:false,
                    axisLabel: {
                        interval: 0,
                    },

                },
                yAxis: {
                    max: 180,
                    min: 40
                },
                series: [{
                    name: '心率',
                    type: 'line',
                    data: Pulse,
                    markLine: {
                        symbol: ['none', 'none'], //去掉箭头
                        itemStyle: {
                            normal: {
                                lineStyle: {
                                    type: 'dashed',
                                    color: { //设置渐变
                                        type: 'linear',
                                        // x: 0,
                                        y: 0,
                                        x2: 0,
                                        y2: 1,
                                        colorStops: [{
                                            offset: 0,
                                            color: 'red ' // 0% 处的颜色
                                        }, {
                                            offset: 1,
                                            color: 'red' // 100% 处的颜色
                                        }],
                                        global: false // 缺省为 false
                                    }
                                },
                            }
                        },
                        data: [{
                            yAxis: 60,
                        }, {
                            yAxis: 100,
                        }]
                    },

                }, ],
                color: ['#3366CC'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'line'
                    }
                },
                dataZoom: [ //滑动条
                    {
                        type: 'inside',
                        realtime: true,
                        start: startLength,
                        end: 100,
                        startValue: 0
                    }
                ],
            };
            myChart2.setOption(option2);

        }

    })



}
getTime(getPreMonth(), getNowMonth());